<?php

namespace Sharks\Core\Support\Constaints;

use Sharks\Core\Support\Base\DefValue;

/**
 * 验证规则接口
 */
abstract class Rule {
    protected $value;
    protected $msg;

    public function __construct($value, $msg) {
        $this->value = $value;
        $this->msg = DefValue::isEmpty($msg, 'validate error');
    }

    public abstract function validate();

    public function getMessage() {
        return $this->msg;
    }
}